import { Component, OnInit } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Router} from '@angular/router'
@Component({
  selector: 'app-tag-list',
  templateUrl: './tag-list.component.html',
  styleUrls: ['./tag-list.component.css']
})
export class TagListComponent implements OnInit {
public tags
  constructor(
    private http:HttpClient,
    private router:Router
  ) { }
getTags(){
this.http.get('http://localhost:3000/tags').toPromise().then((data=>{
  console.log(data)
  this.tags =data
}))
}
removeTag(id,e){
  e.preventDefault()
  if(window.confirm("确认删除此标签？")){
    this.http.delete(`http://localhost:3000/tags/${id}`).toPromise().then((data=>{
      console.log(data)
      this.getTags()
    }))
  }else{
    return
  }
}

  ngOnInit(): void {
this.getTags()
console.log("标签页")

  }

}
